//
//  YMSessionRequest.m
//  YueYue
//
//  Created by LiuYu on 2024/10/24.
//

#import "YMSessionRequest.h"

@implementation YMAvailableChartCardsResult

@end

@implementation YMSessionRequest
{
    YMSessionRequestType _type;
    NSDictionary *_params;
}

- (instancetype)initWithType:(YMSessionRequestType)type params:(nonnull NSDictionary *)params
{
    self = [super init];
    if (self) {
        _type = type;
        _params = params;
    }
    return self;
}

- (NSString *)requestUrl
{
    if (_type == YMSessionRequestTypeAvailableChartCards) {
        return @"/user/chat/card/count";
    }
    
    if (_type == YMSessionRequestTypeSendAble) {
        return @"/user/send/message";
    }
    
    return @"";
}

- (YTKRequestMethod)requestMethod
{
    if (_type == YMSessionRequestTypeAvailableChartCards) {
        return YTKRequestMethodGET;
    }
    
    if (_type == YMSessionRequestTypeSendAble) {
        return YTKRequestMethodGET;
    }
    
    return YTKRequestMethodPOST;
}

- (id)requestArgument
{
    return _params;
}

- (YMAvailableChartCardsResult *)objectResult
{
    YMAvailableChartCardsResult *translacte;
    NSDictionary *data = [self.result valueForKey:@"data"];
    if (![data isKindOfClass:[NSDictionary class]]){
        return translacte;
    }
    translacte = [YMAvailableChartCardsResult mj_objectWithKeyValues:data];
    return translacte;
}

@end
